#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "Editors/IModelEditor.h"

QT_BEGIN_NAMESPACE
class QTextEdit;
class QString;
class QTabWidget;
QT_END_NAMESPACE

class GraphEditor;
class GenEditor;
class ModelPreview;

//! @brief Gen2 main windows.
class MainWindow : public QMainWindow
{
	Q_OBJECT
private:
	//! Main tab control.
	QTabWidget *_tab;

	//! Textual model editor.
	GenEditor *_genEditor;
	//! Model preview.
	ModelPreview *_cppPreview;
	//! Graphical model editor.
	GraphEditor *_graphEditor;

	//! Editor that perform editing actions.
	IModelEditor* _editor;
	//! Editor that currently display model.
	IModelEditor* _currentView;

	//! Tabs indexes.
	int _graphTab, _modelTab, _previewTab;

	//! Current model.
	SemanticModel::ModelPtr _currentModel;

	//! "Edit graph..." action
	QAction* _editGraphAction;

	QString _path;

public:
	MainWindow(QWidget *parent = 0);

public slots:
	void about();
	void options();
	void newFile();
	void editGraph();
	bool openFile();
	bool saveFile();
	bool saveAsFile();
	void tabChanged(int index);

private:
	void setupControls();
	void setupMenu();
	IModelEditor* getEditor(int index);
	
	void writeSettings();
	void readSettings();
	void closeEvent(QCloseEvent *event);

	bool processChanges();
	void syncCurrentTab();
};

#endif
